From Cppreference
|
|
|
|
|
|
|
| template< class T, class U > struct is_same;
|
|
(C++11 feature)
|
|
|
|
If T and U name the same type with the same const-volatile qualifications, provides the member constant value equal to true. Otherwise value is false.
Member objects
|
|
| value
|
true if T and U is the same type, false otherwise (public member object)
|
[edit] Equivalent definition
template<class T, class U>
struct is_same : std::false_type {};
template<class T>
struct is_same<T, T> : std::true_type {};
|
[edit] Example
#include <type_traits>
int main()
{
static_assert(std::is_same<int, int>::value, "int == int"); // passed
typedef int foo;
static_assert(std::is_same<int, foo>::value, "int == foo"); // passed
static_assert(std::is_same<int, const int>::value, "int == const int"); // failed
}
[edit] See also